CC			=	gcc
CXX			=	g++
ASM			=	nasm
ALINK		=	alink
DEPS		=	main.c
OBJ			=	main.o
CFLAGS		=	-g
CXXFLAGS	=	-g
LDFLAGS		= 	-L.
INCLUDES	=	-I.

all: main

main: main.o
	$(CC) -g -o main.exe main.o $(LDFLAGS)

main.o: main.c
	$(CC) $(CFLAGS) $(INCLUDES) -g -c -o main.o main.c
	
matrix: matrix.obj
	$(ALINK) -subsys console matrix.obj -oPE -dll -o matrix.dll
	pexports matrix.dll > matrix.def
	dlltool -D matrix.dll -d matrix.def -l libmatrix.a
	
matrix.obj: matrix.asm
	$(ASM) -g -f obj -l matrix.lst -o matrix.obj matrix.asm
	
clean:
	del *.o main.exe main.s *.a *.obj *.dll *.def *.lst
	
app1: app1.o
	$(CC) -o app1.exe app1.obj $(LDFLAGS)

app1.o: app1.asm
	$(ASM) -f win32 -o app1.obj -l app1.lst app1.asm

asm:
	$(CC) $(INCLUDES) -S -masm=intel -m32 -fno-asynchronous-unwind-tables -o main.s main.c
#	$(CC) $(INCLUDES) -S -masm=intel -m32 -fno-asynchronous-unwind-tables -o mx_funcs.s mx_funcs.c
	
example2_dll: example2_dll.o
	gcc -Wl,-s -shared -mthreads -Wl,--out-implib,libmx_funcs.a -o example2_dll.dll example2_dll.o  
	
example2_dll.o: example2_dll.c
	gcc -c -O2 -Wall -I. -o example2_dll.o example2_dll.c
